home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / filutil / ygrep401.zip / BITLIST.H < prev    next >
C/C++ Source or Header  |  1995-01-30  |  4KB  |  120 lines

  1. /*
  2. //    SCCS Id: "@(#)bitlist.h        (C) Yves Roumazeilles    95/01/30";
  3. //
  4. //    Version: 1.03b
  5. */
  6.  
  7. #ifndef    __BITLIST_H__
  8. #define    __BITLIST_H__    
  9.  
  10. #include    <memory.h>
  11. #include    <string.h>
  12.  
  13. #ifndef    T_BASE_TYPE
  14. # define    T_BASE_TYPE    unsigned long
  15. #endif
  16. #define    SZ_BASE_TYPE        sizeof(T_BASE_TYPE)
  17. #define    BITS_BASE_TYPE        (SZ_BASE_TYPE*8)
  18. #define    NUM_BASE_ELEM(x)    (x)->Size
  19.  
  20.  
  21. typedef    struct tagBList {
  22.     int            Size;
  23.     int            iWordSize;
  24.     int            bAllocated;
  25. #ifdef    NUMTAG
  26.     int            iTag;        /* temporary numbered tag */
  27. #endif
  28. #ifdef    WINVER
  29.     HANDLE            hBits;
  30.     T_BASE_TYPE FAR*    Bits;
  31. #else
  32.     T_BASE_TYPE*        Bits;
  33. #endif
  34. #ifdef    BL_CHECK
  35.     long            lTest;        /* temporary test pattern location */
  36. #endif
  37. } BLIST;
  38. #ifdef    WINVER
  39. typedef    BLIST*        PBLIST;
  40. typedef    BLIST FAR*    LPBLIST;
  41. #else
  42. typedef    BLIST*        PBLIST;
  43. typedef    BLIST*        LPBLIST;
  44. typedef int        BOOL;
  45. #define FALSE        0
  46. #define TRUE        1
  47. #endif
  48.  
  49.  
  50.  
  51. /* Basic operations declaration */
  52.  
  53. #define    INDEX_BIT(n)    ((n) / BITS_BASE_TYPE)
  54. #define    MASQUE_BIT(n)    (1L << ((n) % BITS_BASE_TYPE))
  55.  
  56.  
  57. #define    BSET(t, n)    (t).Bits[INDEX_BIT(n)] |= MASQUE_BIT(n)
  58. #define    BCHG(t, n)    (t).Bits[INDEX_BIT(n)] ^= MASQUE_BIT(n)
  59. #define    BCLR(t, n)    (t).Bits[INDEX_BIT(n)] &= ~MASQUE_BIT(n)
  60. #define    BTST(t, n)    ((t).Bits[INDEX_BIT(n)] & MASQUE_BIT(n))
  61. #define    BSET_unlocked(t, n)    BitListLock(&t);\
  62.                 (t).Bits[INDEX_BIT(n)] |= MASQUE_BIT(n);\
  63.                 BiTListUnlock(&t)
  64. #define    BCHG_unlocked(t, n)    BitListLock(&t);\
  65.                 (t).Bits[INDEX_BIT(n)] ^= MASQUE_BIT(n);\
  66.                 BiTListUnlock(&t)
  67. #define    BCLR_unlocked(t, n)    BitListLock(&t);\
  68.                 (t).Bits[INDEX_BIT(n)] &= ~MASQUE_BIT(n);\
  69.                 BiTListUnlock(&t)
  70. #define    BTST_unlocked(t, n)    BitListLock(&t);\
  71.                 ((t).Bits[INDEX_BIT(n)] & MASQUE_BIT(n));\
  72.                 BiTListUnlock(&t)
  73.  
  74. #ifdef    WINVER
  75. #ifdef    BITLIST_BUILD
  76. #define    BLCALL    FAR PASCAL
  77. #else
  78. #define    BLCALL    FAR
  79. #endif
  80. #else
  81. #define    BLCALL    
  82. #endif
  83. extern BOOL BLCALL    BitListIsDebug( void );
  84.  
  85. extern void BLCALL    BitListDebugOutput(LPBLIST x);
  86. extern void BLCALL    BitListClr(LPBLIST x);
  87. extern void BLCALL    BitListSet(LPBLIST x);
  88. extern void BLCALL    BitListChg(LPBLIST x);
  89. extern int BLCALL    BitListCtorClr(LPBLIST x, int n);
  90. #define    BitListCtor(x,n)    BitListCtorClr(x,n);
  91. extern int BLCALL    BitListCtorSet(LPBLIST x, int n);
  92. extern int BLCALL    BitListEmpty(LPBLIST x);
  93. extern void BLCALL    BitListCopy(LPBLIST x, LPBLIST y);
  94. extern int BLCALL    BitListCopyCtor(LPBLIST x, LPBLIST y, int n);
  95. extern void BLCALL    BitListLShift(LPBLIST x, int n);
  96. extern void BLCALL    BitListRShift(LPBLIST x, int n);
  97. extern void BLCALL    BitListOr(LPBLIST x, LPBLIST y);
  98. extern void BLCALL    BitListCopyOr(LPBLIST x, LPBLIST y, LPBLIST z);
  99. extern void BLCALL    BitListAnd(LPBLIST x, LPBLIST y);
  100. extern void BLCALL    BitListCopyAnd(LPBLIST x, LPBLIST y, LPBLIST z);
  101. extern void BLCALL    BitListAndNot(LPBLIST x, LPBLIST y);
  102. extern void BLCALL    BitListOrNot(LPBLIST x, LPBLIST y);
  103. extern void BLCALL    BitListNot(LPBLIST x);
  104. extern void BLCALL    BitListAdd(LPBLIST x, LPBLIST y);
  105. extern void BLCALL    BitListSub(LPBLIST x, LPBLIST y);
  106. extern void BLCALL    BitListMultiply(LPBLIST x, LPBLIST y);    /* not implemented */
  107. extern void BLCALL    BitListDivide(LPBLIST x, LPBLIST y);    /* not implemented */
  108. extern int BLCALL    BitListEqual(LPBLIST x, LPBLIST y);
  109. extern int BLCALL    BitListEqualZero(LPBLIST x);
  110. extern int BLCALL    BitListCompare(LPBLIST x, LPBLIST y);
  111. #ifdef    WINVER
  112. extern int BLCALL    BitListLock(LPBLIST x);
  113. extern int BLCALL    BitListUnlock(LPBLIST x);
  114. #else
  115. #define    BitListLock(x)
  116. #define    BitListUnlock(x)
  117. #endif
  118.  
  119. #endif    /* __BITLIST_H__ */
  120.